(deftemplate persoana
    (slot nume)
    (slot sex)
    (slot parinte)
    (slot partener)
    )
(assert (persoana(nume Petru)(sex M)(parinte null)(partener Veta)))
(assert (persoana(nume Veta)(sex F)(parinte null)(partener Petru)))
(assert (persoana(nume Teodor)(sex M)(parinte null)(partener Alberta)))
(assert (persoana(nume Alberta)(sex F)(parinte null)(partener Teodor)))
(assert (persoana(nume Hans)(sex M)(parinte null)(partener Armando)))
(assert (persoana(nume Armando)(sex M)(parinte Veta)(partener Hans)))
(assert (persoana(nume Miguel)(sex M)(parinte Veta)(partener null)))
(assert (persoana(nume George)(sex M)(parinte Veta)(partener Maria)))
(assert (persoana(nume Maria)(sex F)(parinte Alberta)(partener George)))
(assert (persoana(nume Vasilica)(sex F)(parinte alberta)(partener Mirela)))
(assert (persoana(nume Mirela)(sex F)(parinte null)(partener Vasilica)))
(assert (persoana(nume Nemo)(sex M)(parinte Hans)(partener null)))
(assert (persoana(nume Ionel)(sex M)(parinte Maria)(partener null)))
(assert (persoana(nume Oana)(sex F)(parinte Maria)(partener null)))
(assert (persoana(nume Vanessa)(sex F)(parinte Mirela)(partener null)))

(defrule mama1
    (persoana (nume ?nc)(parinte ?np))
    (persoana(nume ?np)(sex F))
=>
	(printout t "Persoana" ?nc"are mama" ?np crlf)
    )

(defrule mama2
    (persoana (nume ?nc)(parinte ?np))
    (persoana(nume ?np)(partener ?npp))
    (persoana(nume ?npp)(sex F))
=>
	(printout t "Persoana" ?nc"are mama" ?npp crlf)
    )
(run)

(defrule mama3
    (persoana (nume ?nc)(parinte ?np))
    (persoana (nume ?np) (sex M))
    =>
    (printout t "Persoana " ?nc " are mama " ?np crlf)
    )

(run)

(printout t"--------------------------------------------------------" crlf)

(defrule sotie
    (persoana (nume ?nc) (partener ?p))
    (persoana (nume ?nc) (sex M))
    =>
     (printout t "Persoana " ?nc " are sotia " ?p crlf)
    )


(defrule sotie2
    (persoana (nume ?nc) (partener ?p))
    (persoana (nume ?nc) (sex F))
    =>
     (printout t "Persoana " ?nc " are sotul " ?p crlf)
    )

(run)

(printout t"--------------------------------------------------------" crlf)
(defrule bunici1
    (persoana(nume ?nc)(parinte ?np))
    (persoana(nume ?np)(parinte ?npp))
    (persoana(nume ?npp)(partener ?nppp))
    =>
    (printout t "Persoana " ?nc " are bunicii " ?npp " si " ?nppp  crlf)
    )
(defrule bunici2
    (persoana(nume ?nc)(parinte ?np))
    (persoana(nume ?np)(partener ?npp))
    (persoana(nume ?npp)(parinte ?nppp))
    (persoana(nume ?nppp)(partener ?npppp))
    =>
    (printout t "Persoana " ?nc " are bunicii " ?nppp " si " ?npppp crlf)
    )


(printout t"--------------------------------------------------------" crlf)
(defrule unchi
    (persoana (nume ?n) (parinte ?p))
    (persoana (nume ?p) (parinte ?h) )
    (persoana (nume ?u)(parinte ?h))
    ;(persoana (nume ?v)(parinte ?u))

    =>
    (printout t "Persoana " ?n " are ca unchi pe " ?u crlf))

(run)